import React from 'react';
import { history } from 'umi';
import { ConfigProvider } from 'antd';
import zhCN from 'antd/es/locale/zh_CN';

// 切换路由时触发
export function onRouteChange({ location, routes }) {
  if (!routes[0].routes.some(item => item.path === location.pathname)) {
    // 当打开的是不存在的页面时，跳转到404
    history.replace('/404');
  }
}

export function rootContainer(container) {
  // 配置国际化
  return React.createElement(ConfigProvider, { locale: zhCN }, container);
}
